﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PTA.TreeHelper
{
    public interface ITreeDal<N>
        where N : BaseTreeNode, new()
    {
        /// <summary>
        /// 添加一个节点,并返回这个节点的信息
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        N Add(N node);

        /// <summary>
        /// 删除一个节点
        /// </summary>
        /// <param name="nid"></param>
        void Delete(int nid);

        /// <summary>
        /// 移动一个节点
        /// </summary>
        /// <param name="nid"></param>
        /// <param name="direction"></param>
        void Move(int nid, MoveDirection direction);

        /// <summary>
        /// 获取一个节点的信息
        /// </summary>
        /// <param name="nid">节点名称</param>
        /// <returns></returns>
        N GetNode(int nid);

        /// <summary>
        /// 获取一个所有者的所有节点信息
        /// </summary>
        /// <param name="ownerId">所有者编号</param>
        /// <param name="level">获取到第多少级节点(0表示所有级别的节点)</param>
        /// <returns></returns>
        List<N> GetNodeList(int ownerId, int level = 0);

        /// <summary>
        /// 获取指定节点的父节点和子节点的信息
        /// </summary>
        /// <param name="ownerId">节点所有者</param>
        /// <param name="nodes">要获取的节点编号</param>
        /// <param name="parent">是否包含父节点信息,会获取到顶级节点</param>
        /// <param name="child">是否包含子节点信息</param>
        /// <param name="level">获取到第几级节点,如果为0,获取所有子节点</param>
        /// <returns></returns>
        List<N> GetNodeList(int ownerId, List<int> nodes, bool parent = false, bool child = true, int level = 0);

        /// <summary>
        /// 获取指定节点的父节点和子节点的信息
        /// </summary>
        /// <param name="ownerId">节点所有者</param>
        /// <param name="nodes">要获取的节点信息</param>
        /// <param name="parent">是否包含父节点信息,会获取到顶级节点</param>
        /// <param name="child">是否包含子节点信息</param>
        /// <param name="level">获取到第几级节点,如果为0,获取所有子节点</param>
        /// <returns></returns>
        List<N> GetNodeList(int ownerId, int nid, bool parent = false, bool child = true, int level = 0);
    }

}
